package com.net.xpay.partner.controller.partner;

import com.net.common.model.ResultPagedList;
import com.net.xpay.common.domain.partner.Partner;
import com.net.xpay.common.domain.stat.UserSafePayTransMonthStat;
import com.net.xpay.common.manager.stat.UserSafePayTransMonthStatManager;
import com.net.xpay.core.model.UserSafePayTransMonthStatSearchModel;
import com.net.xpay.partner.secutiry.RequestUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * 用户安全付月转账统计
 **/
@RestController
@RequestMapping("/partner/user-safe-pay-trans-month-stat")
@Api(tags = "运营/用户安全付月转账统计",description = "用户安全付月转账统计")
public class UserSafePayTransMonthStatController {

    @Autowired
    private UserSafePayTransMonthStatManager userSafePayTransMonthStatManager;

    @ApiOperation(value = "用户安全付月转账统计")
    @PostMapping(value = "/search")
    public ResultPagedList<UserSafePayTransMonthStat> search(@ApiIgnore @RequestUser Partner partner, @RequestBody UserSafePayTransMonthStatSearchModel searchModel){
        searchModel.setUserId(searchModel.getUserId());
        searchModel.setPartnerId(partner.getId());
        // 根据查询条件进行查询
        List<UserSafePayTransMonthStat> userTransMonthStatList = userSafePayTransMonthStatManager.search(searchModel);
        // 查询带条件后数据的条数
        long count = userSafePayTransMonthStatManager.searchCount(searchModel);
        return new ResultPagedList<>(userTransMonthStatList,count,searchModel);
    }
}